﻿using ZyGames.Framework.Game.Contract;
using ZyGames.DZPocker.Bll.Logic;
using ZyGames.DZPocker.Tools;
using ZyGames.DZPocker.Model;

namespace ZyGames.DZPocker.Script.CsScript.Action
{
	/// <summary>
	/// 请求个人金币数量
	/// </summary>
	public class Action10063 : BaseAction
	{
		private int userId;
		private int diamodNum = 0;
		private int costDiamodNum = 30;
		private bool result = false;
		private string log = "";
		public Action10063(HttpGet actionGetter)
			: base((short)ActionType.DZApplyDiamodCount, actionGetter)
		{
		}
		public override bool GetUrlElement()
		{
			if (httpGet.GetInt("UserId", ref userId))
			{
				return true;
			}
			return false;
		}

		public override bool TakeAction()
		{
			var currentGameUser = GameTable.Current.GetUser(userId);
			if (currentGameUser == null)
			{
				Tool.WriteWarmingLine("消息10063玩家不存在");
				log = "信息有误";
				result = false;
				return true;
			}
			this.diamodNum = currentGameUser.GameCoin;
			this.costDiamodNum = currentGameUser.HaveChangedNickName ? ConfigEnvSet.GetInt("GameSetting.ChangeNickNameCost", 30) : 0;
			result = true;
			return true;
		}

		public override void BuildPacket()
		{
			this.PushIntoStack(this.result);
			this.PushIntoStack(this.log);
			this.PushIntoStack(this.diamodNum);
			this.PushIntoStack(this.costDiamodNum);
		}
	}
}
